package com.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Product entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "product", catalog = "dangdang")
public class Product implements java.io.Serializable {

	// Fields
	private static final long serialVersionUID = 1L;
	private Integer id;
	private ThirdCategory thirdCategory;
	private String name;
	private String description;
	private String addTime;
	private Double marketPrice;
	private Double dangPrice;
	private String keywords;
	private Boolean hasDeleted;
	private String pic;
	private Set<Book> books = new HashSet<Book>(0);

	// Constructors

	/** default constructor */
	public Product() {
	}

	/** minimal constructor */
	public Product(ThirdCategory thirdCategory, String name) {
		this.thirdCategory = thirdCategory;
		this.name = name;
	}

	/** full constructor */
	public Product(ThirdCategory thirdCategory, String name,
			String description, String addTime, Double marketPrice,
			Double dangPrice, String keywords, Boolean hasDeleted, String pic,
			Set<Book> books) {
		this.thirdCategory = thirdCategory;
		this.name = name;
		this.description = description;
		this.addTime = addTime;
		this.marketPrice = marketPrice;
		this.dangPrice = dangPrice;
		this.keywords = keywords;
		this.hasDeleted = hasDeleted;
		this.pic = pic;
		this.books = books;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "category_id", nullable = false)
	public ThirdCategory getThirdCategory() {
		return this.thirdCategory;
	}

	public void setThirdCategory(ThirdCategory thirdCategory) {
		this.thirdCategory = thirdCategory;
	}

	@Column(name = "name", nullable = false, length = 100)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "description", length = 100)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "add_time", length = 20)
	public String getAddTime() {
		return this.addTime;
	}

	public void setAddTime(String addTime) {
		this.addTime = addTime;
	}

	@Column(name = "market_price", precision = 22, scale = 0)
	public Double getMarketPrice() {
		return this.marketPrice;
	}

	public void setMarketPrice(Double marketPrice) {
		this.marketPrice = marketPrice;
	}

	@Column(name = "dang_price", precision = 22, scale = 0)
	public Double getDangPrice() {
		return this.dangPrice;
	}

	public void setDangPrice(Double dangPrice) {
		this.dangPrice = dangPrice;
	}

	@Column(name = "keywords", length = 200)
	public String getKeywords() {
		return this.keywords;
	}

	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	@Column(name = "has_deleted")
	public Boolean getHasDeleted() {
		return this.hasDeleted;
	}

	public void setHasDeleted(Boolean hasDeleted) {
		this.hasDeleted = hasDeleted;
	}

	@Column(name = "pic", length = 200)
	public String getPic() {
		return this.pic;
	}

	public void setPic(String pic) {
		this.pic = pic;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "product")
	public Set<Book> getBooks() {
		return this.books;
	}

	public void setBooks(Set<Book> books) {
		this.books = books;
	}

}